<template>
  <button @click="comName = 'left'">显示left组件</button>
  <button @click="comName = 'Right'">显示Right组件</button>
  <component :is="comName"> </component>
</template>

<script>
import Left from "./components/Left.vue"
import Right from "./components/Right.vue"
export default {
  name: "App",
  data() {
    return {
      comName: "Left",
    }
  },
  // 注册组件
  components: { Left, Right },
}
// 由于V3支持V2的绝大多数特性,在V3里面写V2语法都是可以跑起来的
</script>

<style></style>
